<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>信息管理系统</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <link href="/style/basic_layout.css" rel="stylesheet" type="text/css"/>
    <link href="/style/common_style.css" rel="stylesheet" type="text/css"/>
    <script type="text/javascript" src="/js/jquery/jquery.js"></script>
    <script type="text/javascript" src="/js/plugins/artDialog/jquery.artDialog.js?skin=blue"></script>
    <script type="text/javascript" src="/js/jquery-form/jquery.form.min.js"></script>
    <script>
        //权限移动
        $(function () {
            //将左边全部提交到右边
//            moveAll("selectAll","all_permissions","self_permissions");
//            //将右边全部提交到左边
//            moveAll("deselectAll","self_permissions","all_permissions");
//
//            move("select","all_permissions","self_permissions");
//
//            move("deselect","self_permissions","all_permissions");

            $("#selectAll").click(function () {
                $("#all_permissions option").appendTo($("#self_permissions"));
            });

            $("#deselectAll").click(function () {

                $("#self_permissions option").appendTo($("#all_permissions"))
            })

            $("#select").click(function () {
                $("#all_permissions option:selected").appendTo($("#self_permissions"))
            })

            $("#deselect").click(function () {
                $("#self_permissions option:selected").appendTo($("#all_permissions"))

            })


            //将表单使用ajax提交
            $("#editForm").ajaxForm(function (data) {
                //弹出框,提示操作成功
                var dialog = $.dialog({
                    title:"提示",
                    content:data.msg,
                });
                //如果保存成功跳转回list
                if(data.success){
                    dialog.button({name:"确定" ,callback:function () {
                        window.location.href = "/systemMenu/list.do";
                    }});
                }else{
                    dialog.button({name:"确定"})
                }
            });

            //去掉所有的权限列表中已经选择的权限
            //获取右边所有的option 的id
            var ids = $(".self_permissions option").map(function (index,item) {
                return $(item).val();

            });

            $(".all_permissions option").each(function (index,item) {

                if($.inArray($(item).val(),ids) > -1){
                    $(item).remove()
                }
            });

        });
    </script>

</head>
<body>
<form name="editForm" action="/systemMenu/saveorupdate.do" method="post" id="editForm">
    <input type="hidden" value="${systemMenu.id}" name="id">
    <div id="container">
        <div id="nav_links">
            <span style="color: #1A5CC6;">菜单编辑</span>
            <div id="page_close">
                <a>
                    <img src="/images/common/page_close.png" width="20" height="20" style="vertical-align: text-top;"/>
                </a>
            </div>
        </div>
        <div class="ui_content">
            <table cellspacing="0" cellpadding="0" width="100%" align="left" border="0">
                <tr>
                    <td class="ui_text_rt" width="140">父级菜单</td>
                    <td class="ui_text_lt">
                        <input  value="${parentName}" disabled readonly class="ui_input_txt02"/>
                        <input type="hidden" name="parent.id" value="${parentId}" >
                    </td>
                </tr>
                <tr>
                    <td class="ui_text_rt" width="140">菜单名称</td>
                    <td class="ui_text_lt">
                        <input name="name" value="${systemMenu.name}" class="ui_input_txt02"/>
                    </td>
                </tr>
                <tr>
                    <td class="ui_text_rt" width="140">菜单编号</td>
                    <td class="ui_text_lt">
                        <input  name="sn" value="${systemMenu.sn}" class="ui_input_txt02"/>
                    </td>
                </tr>
                <tr>
                    <td class="ui_text_rt" width="140">URL</td>
                    <td class="ui_text_lt">
                        <input name="url" value="${systemMenu.url}" class="ui_input_txt02"/>
                    </td>
                </tr>


                <td class="ui_text_lt">
                    &nbsp;<input type="submit" value="确定保存" class="ui_input_btn01"/>
                    &nbsp;<input id="cancelbutton" type="button" value="重置" class="ui_input_btn01"/>
                </td>
            </table>
        </div>
    </div>
</form>
</body>
</html>
